package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {


//    SetmealVO update(Setmeal setmeal);

    /**
     * 根据分类ID查询套餐数量
     * @param categoryId
     * @return
     */
    @Select("select count(*) from setmeal where category_id=#{categoryId}")
    int countByCategoryId(Long categoryId);

    /**
     * 动态修改套餐
     * @param setmeal
     */
    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 根据ID查询套餐
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal where id=#{setmealId}")
    Setmeal queryById(Long setmealId);

    /**
     *分页查询套餐
     * @param setmealPageQueryDTO
     * @return
     */
    Page<Setmeal> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * 新增套餐
     * @param setmeal
     */
    @AutoFill(OperationType.INSERT)
    void insert(Setmeal setmeal);

    /**
     * 根据ID集合批量删除套餐
     * @param id
     */
    @Delete("delete from setmeal where id=#{id}")
    void delete(Long id);

    /**
     * 根据分类ID查询套餐
     * @param dish
     * @return
     */
    @Select("select * from setmeal where category_id=#{categoryId} and status=#{status}")
    List<Setmeal> queryByCategoryId(Dish dish);

    /**
     * 根据条件统计套餐数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

}
